﻿/** 窗口类
*/
(function (win, undefined) {
    F5Frame.register("F5Frame", function (cg) {
        this.MsgDialog = function () {
            //继承:对象冒充
            this.newMethod = F5Frame.ObjBase; //把_objbase方法赋给newMethod，
            this.newMethod(); //调用newMethod
            delete this.newMethod; //删除newMethod
            //创建窗口(坐标,背景)
            this.Create = function (options) {
                this._x = options.x || 0;
                this._y = options.y || 0;

                this.imgs = [options.file || srcObj.FormBgSrc, ];
                this.setImage(this.imgs[0]);
                this._isform = true;
                F5Frame.addGameObject(this);



                //每个窗口显示在不同的层级,窗口下的对象也显示在各自的层级中
                this.drag(true);
                this.setAlign("lefttop");


                this.btn_close = new F5Frame.Text().Create({ text: "X", x: this.getWidth() - 15, y: 10, color: "#fe44ee" });
                this.txt_title = new F5Frame.Text().Create({ text: options.title || "提示", x: 10, y: 10, color: "#00eefe" });
                this.txt_msg = new F5Frame.Text().Create({ text: options.msg || "提示消息", x: this.getWidth() / 2, y: this.getHeight() / 2, align: "conter", color: "#00eefe" });

                this.btn_confirm = new F5Frame.Button().Create(this.getWidth() * 0.3, this.getHeight() * 0.7,
                [srcObj.Btn0101, srcObj.Btn0102, srcObj.Btn0103, srcObj.Btn0103]);
                this.btn_confirm.click(options.func_ok || this.click_ok, { arg1: options.func_ok_arg1});
                this.btn_cancel = new F5Frame.Button().Create(this.getWidth() * 0.7, this.getHeight() * 0.7,
                [srcObj.Btn0101, srcObj.Btn0102, srcObj.Btn0103, srcObj.Btn0103]);
                this.btn_cancel.click(options.func_cancel || this.click_cancel, { arg1: options.func_cancel_arg1 });

                this.appendChild(this.btn_confirm);
                this.appendChild(this.btn_cancel);
                this.appendChild(this.txt_title);
                this.appendChild(this.txt_msg);
                this.appendChild(this.btn_close);

                this.btn_close.click(F5Frame.hideGameForm, { arg1: this });

                return this;
            }
            //对象选中
            this.draw_pick = function (context) {
                if (this._onpick && this._pick) {
                }
            }
            //显示窗口,并且置顶
            this.show = function () {
                this._show = true;
                //显示所有子节点
                for (x in this._childObjs) {
                    this._childObjs[x].show();
                }
                F5Frame.sortGameForm(this);
            }
            this.isOnPick = function () {
                return false;
            }
            this.setMsg = function (v) {
                this.txt_msg.setText(v);
            }
            this.click_cancel = function () {
            }
            this.click_ok = function () {
            }
        }
    });

})(window, undefined);